package dto;

// Generated May 6, 2011 4:19:20 PM by Hibernate Tools 3.3.0.GA
import SessionFactory.SessionFactoryUtil;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import static org.hibernate.criterion.Example.create;

/**
 * Home object for domain model class UserWarning.
 * @see dto.UserWarning
 * @author Hibernate Tools
 */
public class UserWarningHome {

    private static final Log log = LogFactory.getLog(UserWarningHome.class);
    private final SessionFactory sessionFactory = SessionFactoryUtil.getInstance();

    public void persist(UserWarning transientInstance) {
        log.debug("persisting UserWarning instance");
        try {
            sessionFactory.getCurrentSession().persist(transientInstance);
            log.debug("persist successful");
        } catch (RuntimeException re) {
            log.error("persist failed", re);
            throw re;
        }
    }

    public void attachDirty(UserWarning instance) {
        log.debug("attaching dirty UserWarning instance");
        try {
            sessionFactory.getCurrentSession().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }

    public void attachClean(UserWarning instance) {
        log.debug("attaching clean UserWarning instance");
        try {
            sessionFactory.getCurrentSession().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }

    public void delete(UserWarning persistentInstance) {
        log.debug("deleting UserWarning instance");
        try {
            sessionFactory.getCurrentSession().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }

    public UserWarning merge(UserWarning detachedInstance) {
        log.debug("merging UserWarning instance");
        try {
            UserWarning result = (UserWarning) sessionFactory.getCurrentSession().merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public UserWarning findById(Integer id) {
        log.debug("getting UserWarning instance with id: " + id);
        try {
            UserWarning instance = (UserWarning) sessionFactory.getCurrentSession().get("dto.UserWarning", id);
            if (instance == null) {
                log.debug("get successful, no instance found");
            } else {
                log.debug("get successful, instance found");
            }
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }

    public List<UserWarning> findByExample(UserWarning instance) {
        log.debug("finding UserWarning instance by example");
        try {
            List<UserWarning> results = (List<UserWarning>) sessionFactory.getCurrentSession().createCriteria("dto.UserWarning").add(
                    create(instance)).list();
            log.debug("find by example successful, result size: "
                    + results.size());
            return results;
        } catch (RuntimeException re) {
            log.error("find by example failed", re);
            throw re;
        }
    }

    public List getwarn(JfMembers member) 
    {
        System.out.println("I am inside getaWarning");
        System.out.println(member.getMemberId()); 
   
        Criteria crt=sessionFactory.getCurrentSession().createCriteria(UserWarning.class).add(Restrictions.eq("jfMembersByMemberId",member));
       
        List list = crt.list();
   
        return list;
    }
    
    
   
}
